Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/myst 708 kill switch #330

Merged
merged 3 commits into from Sep 13, 2018
Merged

Feature/myst 708 kill switch #330

merged 3 commits into from Sep 13, 2018

Conversation

zolia
Copy link
Contributor

@zolia zolia commented Sep 7, 2018

tried to find middle ground between @Waldz and @tadovas remarks.

Copy link
Contributor

@tadovas tadovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConnectOptions as jsonstructure has meaning in endpoints only. Connection manager should at least define own "feature" options, and openvpn client config should define only fine grained methodds like setConnectRetry(infinte). Don't trash the same dto through the system

@@ -19,6 +19,7 @@ package connection

import (
"github.com/mysteriumnetwork/node/communication"
dto2 "github.com/mysteriumnetwork/node/core/node/dto"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid generic packages like DTO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like dto69 more :)

@@ -31,12 +32,12 @@ type DialogCreator func(consumerID, providerID identity.Identity, contact dto.Co

// VpnClientCreator creates new vpn client by given session,
// consumer identity, provider identity and uses state callback to report state changes
type VpnClientCreator func(session.SessionDto, identity.Identity, identity.Identity, state.Callback) (openvpn.Process, error)
type VpnClientCreator func(session.SessionDto, identity.Identity, identity.Identity, state.Callback, dto2.ConnectOptions) (openvpn.Process, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection manager should not depend on external Connect options. At least define them in the same package

@@ -26,6 +27,13 @@ type ClientConfig struct {
*config.GenericConfig
}

// SetConnectOptions sets connect options provided through endpoint parameters
func (c *ClientConfig) SetConnectOptions(options dto.ConnectOptions) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client config should have clear methods -> RestrictReconnects and so on, dont add external dependency as ConnectOptions

@@ -23,6 +23,8 @@ import (
"log"
"strings"

"strconv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2 separations?

@@ -19,6 +19,7 @@ package connection

import (
"github.com/mysteriumnetwork/node/communication"
dto2 "github.com/mysteriumnetwork/node/core/node/dto"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like dto69 more :)

@@ -71,7 +72,7 @@ func NewManager(mysteriumClient server.Client, dialogCreator DialogCreator,
}
}

func (manager *connectionManager) Connect(consumerID, providerID identity.Identity) (err error) {
func (manager *connectionManager) Connect(consumerID, providerID identity.Identity, options dto2.ConnectOptions) (err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100 for DTO, I am doing same wiith serviceOptions for vpn server


// ConnectOptions holds tequilapi connect options
// swagger:model ConnectOptionsDTO
type ConnectOptions struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets have this DTO in connection package

@@ -35,6 +32,9 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"
"github.com/mysteriumnetwork/node/tequilapi/client"
"github.com/mysteriumnetwork/payments/cli/helpers"
mysttoken "github.com/mysteriumnetwork/payments/mysttoken/generated"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 good idea


err := NewDefaultValidator().IsValid(vpnConfig)
if err != nil {
return nil, err
}

clientFileConfig := newClientConfig(runtimeDir, configDir)
clientFileConfig.SetConnectOptions(options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should map ConnectionOptions -> openvpn.config here

@@ -100,13 +102,17 @@ func (client *Client) RegistrationStatus(address string) (RegistrationStatusDTO,
}

// Connect initiates a new connection to a host identified by providerID
func (client *Client) Connect(consumerID, providerID string) (status StatusDTO, err error) {
func (client *Client) Connect(consumerID, providerID string, disableKill bool) (status StatusDTO, err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets have pass all dto.ConnectOptions as argument


// connect options
// required: false
ConnectOptions dto.ConnectOptions `json:"connectOptions,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's dont have to repeat connectOptions in connectionRequest. IMHO options would be enought in REST contract


// Manager interface provides methods to manage connection
type Manager interface {
// Connect creates new connection from given consumer to provider, reports error if connection already exists
Connect(consumerID identity.Identity, providerID identity.Identity) error
Connect(consumerID identity.Identity, providerID identity.Identity, options dto2.ConnectOptions) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100 for separating openvopn specific things to separate struct

ProviderID string `json:"providerId"`
Identity string `json:"consumerId"`
ProviderID string `json:"providerId"`
ConnectOptions dto.ConnectOptions `json:"connectOptions"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's dont have to repeat connectOptions in connectionRequest. IMHO options would be enought in REST contract

@zolia zolia force-pushed the feature/MYST-708-kill-switch branch 3 times, most recently from f064527 to ac6af31 Compare September 7, 2018 13:58
@Waldz
Copy link
Member

Waldz commented Sep 8, 2018

I imagine transformation between ConnectOption to ClientConfig:

clientConfig.setConnectRetry(times)
clientConfig.setConnectRetryInfinite()

@zolia zolia force-pushed the feature/MYST-708-kill-switch branch 3 times, most recently from deeed2f to 692f004 Compare September 10, 2018 09:27
@zolia
Copy link
Contributor Author

zolia commented Sep 10, 2018

Branch rebased on master

@zolia zolia force-pushed the feature/MYST-708-kill-switch branch 3 times, most recently from 2c446ef to d098d64 Compare September 11, 2018 10:55
@zolia zolia self-assigned this Sep 12, 2018
@zolia zolia force-pushed the feature/MYST-708-kill-switch branch from ae5b821 to 924d7fa Compare September 12, 2018 10:59
@zolia zolia force-pushed the feature/MYST-708-kill-switch branch from 924d7fa to 6d3226f Compare September 12, 2018 11:27
Copy link
Contributor

@tadovas tadovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMing this now. But for future reference:
Connection manager should be responsible for tracking service consuming session (promises etc.) and managing underlying payable service. Therefore service abstraction is needed where concrete service will provide and manage all features expected by consumer. I.e. firewall style traffic blocking in case of VPN fails is only needed for Layer3 tunneling. Proxy style service already has it - if proxy conneciton is lost and proxy is set in system settings - no connection will go out by default.

@zolia zolia merged commit 3a306c1 into master Sep 13, 2018
@zolia zolia deleted the feature/MYST-708-kill-switch branch September 13, 2018 07:00
@zolia zolia mentioned this pull request Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants